<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="first">first</div>
    <div id="second">second</div>
    <button onclick="remove()">remove</button>
    <button onclick="replace()">replace</button>
    <script>
        function replace(params) {
            let secondNode = document.getElementById("second")
            let img = document.createElement("img")
            img.setAttribute("src","../img/java.png")
            debugger
            secondNode.parentNode.replaceChild(img,secondNode)
        }
        function remove(){

            let delNode = document.getElementById("first")
            delNode.parentNode.removeChild(delNode)
        }
    </script>
</body>
</html>